using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CoreData;
using System.Runtime.Serialization;
using Helper;
namespace OpenIDHostController.DataContract
{
    [DataContract]
    public class group_module_role_Contract
    {
        [DataMember]
        public long groupid{get;set;}
        [DataMember]
        public long moduleid{get;set;}
        [DataMember]
        public string role{get;set;}
        [DataMember]
        public bool active{get;set;}
         
        public group_module_role_Contract()
        {       
                    role ="";   
        }

        public static group_module_role_Contract ToContract(group_module_role data)
        {
            try
            {
                var model = ConvertObject.ConvertToObject(new group_module_role_Contract());
                Helper.ConvertObject.ConvertEntityToModel(data, ref model);
                return (group_module_role_Contract)model;
            }
            catch
            {
                return null;
            }
        }
        public static group_module_role ToCoreData(group_module_role_Contract data)
        {
            try
            {
                var model = ConvertObject.ConvertToObject(new group_module_role());
                Helper.ConvertObject.ConvertEntityToModel(data, ref model);
                return (group_module_role)model;
            }
            catch
            {
                return null;
            }
        }

        public IList<group_module_role> ToListCoreData(IList<group_module_role_Contract> data)
        {
            var list = new List<group_module_role>();
            foreach (var item in data)
            {
                var model = ConvertObject.ConvertToObject(new group_module_role());
                Helper.ConvertObject.ConvertEntityToModel(item, ref model);
                if(model!=null)
                {
                    list.Add((group_module_role)model);
                }
            }
            if (list.Count <= 0)
                return null;
            return list;
        }
        public IList<group_module_role_Contract> ToListConTract(IList<group_module_role> data)
        {
            var list = new List<group_module_role_Contract>();
            foreach (var item in data)
            {
                var model = ConvertObject.ConvertToObject(new group_module_role_Contract());
                Helper.ConvertObject.ConvertEntityToModel(item, ref model);
                if (model != null)
                {
                    list.Add((group_module_role_Contract)model);
                }
            }
            if (list.Count <= 0)
                return null;
            return list;
        }
        
    }
}
